package io.github.fb513.common.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageInfo<T> {

    public static final int HEADER_LENGTH = 16;

    private Header header;
    private T content;


    public static <T> MessageInfo<T> getJsonMessage(int command) {
        MessageInfo<T> message = new MessageInfo<>();
        Header header = new Header();
        header.setCommand(command);
        message.setHeader(header);
        return message;
    }

    public static <T> MessageInfo<T> getJsonMessage(int command, T content) {
        MessageInfo<T> message = getJsonMessage(command);
        message.setContent(content);
        return message;
    }

    @Data
    public static class Header {
        private int command;
    }
}
